<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="utf-8">
    <title>Layui</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <link rel="stylesheet" href="../lib/layui/css/layui.css"  media="all">
    <!-- 注意：如果你直接复制所有代码到本地，上述css路径需要改成你本地的 -->
</head>
<body>
<!--<script type="text/html" id="barDemo">-->
<!--    <a class="layui-btn layui-btn-xs" lay-event="view">查看</a>-->
<!--    <a class="layui-btn layui-btn-normal layui-btn-xs" lay-event="edit">修改</a>-->
<!--    <a class="layui-btn layui-btn-danger layui-btn-xs" lay-event="del">删除</a>-->
<!--</script>-->

<fieldset class="layui-elem-field layui-field-title">
    <legend>入库商品上架</legend>
</fieldset>

<fieldset class="layui-elem-field layui-field-box">
    <legend>入库单明细</legend>
</fieldset>
<table class="layui-hide" id="test" lay-filter="test"></table>
<!--<div class="layui-table-box">-->
<!--    <div class="layui-table-header">-->


<br/>
<fieldset class="layui-elem-field layui-field-box">
    <legend>推荐货位</legend>
</fieldset>
<table class="layui-hide" id="test1" lay-filter="test1"></table>
<br/>
<br/>

<fieldset class="layui-elem-field layui-field-box">
    <legend>空闲货位</legend>
</fieldset>
<form class="layui-form" action="">
    <div class="layui-inline">
        <label class="layui-form-label">仓库</label>
        <div class="layui-input-inline">
            <select name="warehouseId">
                <option value="">--无限制--</option>
                <option value="1">A1</option>
            </select>
        </div>
    </div>
    <div class="layui-inline">
        <label class="layui-form-label">货架</label>
        <div class="layui-input-inline">
            <select name="goodsShelf">
                <option value="">--无限制--</option>
                <option value="1">1号货架</option>
                <option value="2">2号货架</option>
                <option value="3">3号货架</option>
                <option value="4">4号货架</option>
                <option value="4">4号货架</option>
                <option value="5">5号货架</option>
                <option value="6">6号货架</option>
                <option value="7">7号货架</option>
                <option value="8">8号货架</option>
                <option value="9">9号货架</option>
                <option value="10">10号货架</option>
            </select>
        </div>
    </div>

    <div class="layui-inline">
        <label class="layui-form-label">货层</label>
        <div class="layui-input-inline">
            <div class="layui-inline">
                <select name="shelfLayer">
                    <option value="">--无限制--</option>
                    <option value="1">1层</option>
                    <option value="2">2层</option>
                    <option value="3">3层</option>
                    <option value="4">4层</option>
                    <option value="5">5层</option>
                    <option value="6">6层</option>
                </select>
            </div>
        </div>
    </div>
    <div class="layui-inline">
        <label class="layui-form-label">位置</label>
        <div class="layui-input-inline">
            <div class="layui-inline">
                <input type="text" name="position" placeholder="请输入1-30" autocomplete="off" class="layui-input">
            </div>
        </div>
    </div>
</form>


        <table class="layui-table" id="freeGA">
            <thead>
                <tr>
                    <th class="layui-table-col-special" style="padding-bottom: 5px;padding-top: 5px">
                        <div class="layui-table-cell" style="padding-bottom: 0;padding-top: 0">
                            <span>操作</span>
                        </div>
                    </th>
                    <th class="layui-table-col-special" style="padding-bottom: 5px;padding-top: 5px">
                        <div class="layui-table-cell" style="padding-bottom: 0;padding-top: 0">
                            <span>货位名称</span>
                        </div>
                    </th>

                    <th class="layui-table-col-special" style="padding-bottom: 5px;padding-top: 5px">
                        <div class="layui-table-cell" style="padding-bottom: 0;padding-top: 0;text-align: center">
                            <span>商品名称</span>
                        </div>
                    </th>

                    <th class="layui-table-col-special" style="padding-bottom: 5px;padding-top: 5px">
                        <div class="layui-table-cell" style="padding-bottom: 0;padding-top: 0">
                            <span>商品数量</span>
                        </div>
                    </th>
                    <th class="layui-table-col-special" style="padding-bottom: 5px;padding-top: 5px">
                        <div class="layui-table-cell" style="padding-bottom: 0;padding-top: 0">
                            <span>可存放最大数量</span>
                        </div>
                    </th>
                </tr>
            </thead>
            <tbody>

<!--            表格的一行，如果需要初始几行，复制几次即可，同时隐藏域需要加属性如 id class 自定义属性，则直接在本页面初始和js中相加-->
                <tr>
                    <td style="padding-bottom: 5px;padding-top: 5px;width: 60px">
                        <div class="layui-table-cell" style="padding-bottom: 0;padding-top: 0;width: 100px">
                            <button type="button" name="addNewLine_btn" class="layui-btn layui-btn-normal layui-btn-xs addNewLine_btn" onclick="addTr(this)">+</button>
                            <button type="button" name="delNowLine_btn" class="layui-btn layui-btn-danger layui-btn-xs delNowLine_btn" onclick="delTr(this)">×</button>
                        </div>
                    </td>
<!--                    onclick="showGAInput(this)"-->
                    <td style="padding-bottom: 5px;padding-top: 5px;width: 400px"  class="showGAInput" onclick="showGAInput(this)">
                        <div class="layui-table-cell selGoods" style="padding-bottom: 0;padding-top: 0;display: none"></div>
                        <input type="hidden" name="shelfId" value="">
                        <input type="hidden" name="volume" value="">
                        <div class="layui-inline" ><input type="text" class="layui-input inputTextGA"  value="" onblur="hideGAInput(this)"></div>
                        <div class="layui-inline" ><input type="button" class="layui-btn layui-btn-sm GA_btn" value="选择" onmousedown="addGA(this)"></div>
                    </td>
                    <td style="padding-bottom: 5px;padding-top: 5px;width: 150px">
                        <div class="layui-table-cell selGoods" style="padding-bottom: 0;padding-top: 0;display: none"></div>
<!--                        <input type="hidden" name="goodsId" value="">-->
<!--                        <div class="layui-inline" style="display: none"><input type="text" class="layui-input inputText"  value="" onblur="hideGoodsInput(this)"></div>-->
<!--                        <div class="layui-inline" style="display: none"><input type="button" class="layui-btn layui-btn-sm" value="选择" onmousedown="addGoods(this)"></div>-->

                    </td>
                    <td style="padding-bottom: 5px;padding-top: 5px;width: 150px" onclick="showQuantityInput(this)">
                        <div class="layui-table-cell" style="padding-bottom: 0;padding-top: 0"></div>
                        <div class="layui-inline" style="display: none"><input type="text" class="layui-input inputText" value="" onblur="hideQuantityInput(this)"></div>
                    </td>
                    <td style="padding-bottom: 5px;padding-top: 5px;width: 100px">
                        <div class="layui-table-cell" style="padding-bottom: 0;padding-top: 0"></div>
                    </td>
                </tr>
            </tbody>
        </table>
<br/>
<br/>
<br/>
<div class="layui-input" style="margin: auto;text-align: center">
    <button type="button" class="layui-btn layui-btn-sm onShelf_btn" onclick="onShelf()">确定上架</button>
    <button type="button" class="layui-btn layui-btn-sm">取消</button>
</div>
<input type="hidden" name="page" value="1">
<input type="hidden" name="limit" value="1">
<!--    </div>-->
<!--</div>-->




<!--<script type="text/html" id="toolbarDemo">-->
<!--    <div class="layui-btn-container">-->
<!--        <button class="layui-btn layui-btn-sm" lay-event="insertPurchase">新增采购单</button>-->
<!--        <button class="layui-btn layui-btn-sm" lay-event="auditPurchase">提交审核</button>-->
<!--&lt;!&ndash;<button class="layui-btn layui-btn-sm" lay-event="isAll">验证是否全选</button>&ndash;&gt;-->
<!--    </div>-->
<!--</script>-->

</body>
<script src="lib/jquery-1.12.4.js"></script>
<script src="lib/layui/layui.js" charset="utf-8"></script>
<script>
    var goodsSelect = " <select name=\"goodsId\">";
    var goodsVFirst ;
    layui.use(['table','form'], function() {

        var form = layui.form;
        form.render();
        form.on('warehouseId', function (data) {
            //alert(data.value);
        });



        var table = layui.table;
        var whEntryId = parent.whEntryId;
        // var whEntryId = 40;
        //监听行工具事件
        table.render({
            elem: '#test'
            , url: 'pk/warehouseEntry/listWhEntryDByWhEId'
            , where: {
                whEntryId: whEntryId
            }
            , parseData: function (res) { //res 即为原始返回的数据
                return {
                    "code": 0, //解析接口状态
                    "msg": "", //解析提示文本
                    "count": 1, //解析数据长度
                    "data": res.obj //解析数据列表
                };
            }, done: function (res) {
                // console.log(res.data);
                // var goodsSelect = " <select name=\"goodsId\">";
                var goodsIdList = new Array();
                for (var i = 0; i < res.data.length; i++) {
                    goodsSelect = goodsSelect + "<option value=\""+ res.data[i].goodsId +"\" volume=\""+ res.data[i].volume +"\">"+ res.data[i].goodsName +"</option>";
                    goodsIdList.push(res.data[i].goodsId);
                }
                goodsVFirst = res.data[0].volume;
                goodsSelect = goodsSelect + "</select>";
                addGoodsSelect(goodsSelect);
                // var data = JSON.stringify(goodsIdList);
                table.render({
                    elem: '#test1'
                    , url: 'pk/taskOnShelives/listGAByGoodsId'
                    ,traditional: true
                    // ,data : data
                    // ,method:'post'
                    // ,contentType:'application/json;charset=UTF-8'
                    // ,dataType:'json'
                    ,where : {
                        goodsIdList1 : goodsIdList
                    }
                    , parseData: function (res) { //res 即为原始返回的数据
                        return {
                            "code": 0, //解析接口状态
                            "msg": "", //解析提示文本
                            "count": 1, //解析数据长度
                            "data": res.obj //解析数据列表
                        };
                    }
                    , cellMinWidth: 80 //全局定义常规单元格的最小宽度，layui 2.2.1 新增
                    , cols: [[
                        {type: 'checkbox'}
                        ,{field: 'goodsAllocationCode', title: '货位编号', sort: true}
                        ,{field:'quantityOfGoods', title: '当前数量', sort: true}
                        ,{field:'restOfStorage', title: '剩余可存放数量', sort: true}
                        ,{field:'maxStorage', title: '存放上限', sort: true}
                        ,{field:'restOfStorage', title: '剩余可存放数量', sort: true}
                        ,{field:'quantityOnShelives', title: '请选择上架数量', sort: true,edit:true}
                    ]]
                });
            }
            , cellMinWidth: 80 //全局定义常规单元格的最小宽度，layui 2.2.1 新增
            , cols: [[
                {type: 'checkbox'}
                , {field: 'goodsName', title: '入库商品名称', sort: true}
                , {field: 'warehouseEntryQuantity', title: '需入库数量', sort: true}
                // ,{field:'supplierName', title: '供应商名称', sort: true}
                // ,{field:'statusName', title: '状态', sort: true}
                // ,{fixed: 'right', title:'操作', toolbar: '#barDemo', width:150}
            ]]
        });

        form.on('select',function (data) {
            $("[name='page']").val(1);
            // console.log("这次改变获得的值为"+data.value);
        })


    });

    function onShelf() {

        var data = layui.table.cache.test1;
        var whEntryId = parent.whEntryId;

        var taskOnShelivesList1 = [];
        for (var i in data) {
            taskOnShelivesList1.push({"quantityOnShelives":parseInt(data[i].quantityOnShelives),"shelfId":data[i].id,"warehouseEntryId":whEntryId,"goodsId":data[i].goodsId})
        }
        var trList = $("#freeGA")[0].getElementsByTagName("tr");

        for (var i=1;i<trList.length;i++) {
            var shelfId = $(trList[i]).find("td:eq(1)").find("[name='shelfId']").val();
            if(shelfId==null||shelfId==undefined){

            }else {
                var quantityOnShelives = $(trList[i]).find("td:eq(3)").find("div:first").text();
                var goodsId = $(trList[i]).find("td:eq(2)").find("[name='goodsId']").val();
                var maxStorage = $(trList[i]).find("td:eq(4)").find("div").text();

                taskOnShelivesList1.push({"quantityOnShelives":parseInt(quantityOnShelives),"shelfId":parseInt(shelfId),"warehouseEntryId":whEntryId,"goodsId":parseInt(goodsId),"maxStorage":maxStorage});
            }
        }

        taskOnShelivesList = JSON.stringify(taskOnShelivesList1);

        $.ajax({
            url : "pk/taskOnShelives/insertTaskOnShelives",
            data : taskOnShelivesList,
            type : "POST",
            contentType : "application/json;UTF-8",
            dataType : "json"
            ,success : function (data) {
                layer.msg("上架任务生成成功!");
                parent.layer.closeAll();
            }
        })
    }


    function addTr(Obj) {

        $(Obj).parents('tr').after("<tr>\n" +
            "                    <td style=\"padding-bottom: 5px;padding-top: 5px;width: 100px\">\n" +
            "                        <div class=\"layui-table-cell\" style=\"padding-bottom: 0;padding-top: 0\">\n" +
            "                            <button type=\"button\" name=\"addNewLine_btn\" class=\"layui-btn layui-btn-normal layui-btn-xs addNewLine_btn\" onclick=\"addTr(this)\">+</button>\n" +
            "                            <button type=\"button\" name=\"delNowLine_btn\" class=\"layui-btn layui-btn-danger layui-btn-xs delNowLine_btn\" onclick=\"delTr(this)\">×</button>\n" +
            "                        </div>\n" +
            "                    </td>\n" +
            "<!--                    onclick=\"showGAInput(this)\"-->\n" +
            "                    <td style=\"padding-bottom: 5px;padding-top: 5px;width: 400px\"  class=\"showGAInput\" onclick=\"showGAInput(this)\">\n" +
            "                        <div class=\"layui-table-cell selGoods\" style=\"padding-bottom: 0;padding-top: 0;display: none\"></div>\n" +
            "                        <input type=\"hidden\" name=\"shelfId\" value=\"\">\n" +
            "                        <input type=\"hidden\" name=\"volume\" value=\"\">"+
            "                        <div class=\"layui-inline\" ><input type=\"text\" class=\"layui-input inputTextGA\"  value=\"\" onblur=\"hideGAInput(this)\"></div>\n" +
            "                        <div class=\"layui-inline\" ><input type=\"button\" class=\"layui-btn layui-btn-sm GA_btn\" value=\"选择\" onmousedown=\"addGA(this)\"></div>\n" +
            "                    </td>\n" +
            "                    <td style=\"padding-bottom: 5px;padding-top: 5px;width: 150px\" >\n" +
            "                        <div class=\"layui-table-cell selGoods\" style=\"padding-bottom: 0;padding-top: 0;display: none\"></div>\n" +
            // "                        <input type=\"hidden\" name=\"goodsId\" value=\"\">\n"
                                                    goodsSelect +
            "                    </td>\n" +
            "                    <td style=\"padding-bottom: 5px;padding-top: 5px;width: 150px\" onclick=\"showQuantityInput(this)\">\n" +
            "                        <div class=\"layui-table-cell\" style=\"padding-bottom: 0;padding-top: 0\"></div>\n" +
            "                        <div class=\"layui-inline\" style=\"display: none\"><input type=\"text\" class=\"layui-input inputText\" value=\"\" onblur=\"hideQuantityInput(this)\"></div>"+
            "                    </td>\n" +
            "                    <td style=\"padding-bottom: 5px;padding-top: 5px;width: 100px\">\n" +
            "                        <div class=\"layui-table-cell\" style=\"padding-bottom: 0;padding-top: 0\"></div>\n" +
            "                    </td>\n" +
            "                </tr>")
    }



    function delTr(Obj) {
        var layer = layui.layer;
        if ($(Obj).parents("table").find("tr").length <= 2) {
            layer.msg("最后一行不可删除哦！")
        } else {
            $(Obj).parents('tr').remove();
        }
    }

    function addGoodsSelect(goodsSelect) {
        $("#freeGA").find("td:eq(2)").append(goodsSelect);
    }
    // $("#freeGA").on('click','.showGAInput',function () {
    //     console.log($(this));
    //     $(this).find("div:first").hide();
    //     var m = $(this).find("div:first").text();
    //     $(this).find("div:eq(1)").show();
    //     $(this).find("div:eq(1)").find("input").val(m);
    //     $(this).find("div:eq(2)").show();
    //     $(this).find("input:eq(1)").focus();
    // });
    //
    //
    //
    // $("body :not(.showGAInput)").on('click',function () {
    //     var m =  $(".showGAInput").find("div:eq(1)").find("input").val();
    //     $(".showGAInput").find("div:first").text(m);
    //     $(".showGAInput").find("div:first").show();
    //     $(".showGAInput").find("div:eq(1)").hide();
    //     $(".showGAInput").find("div:eq(2)").hide();
    //     event.stopPropagation();
    // });
    //

    function showGAInput(Obj) {

        $(Obj).find("div:first").hide();
        var m = $(Obj).find("div:first").text();
        // var a = $(Obj).find(".inputText").val();
        if ($(Obj).find("div:eq(1)").css("display")=='none') {
            // $(Obj).append("<div class=\"layui-inline\"><input type=\"text\" class=\"layui-input inputText\"  value=\"" + m + "\" onblur=\"hideGAInput(this)\"></div>");
            $(Obj).find("div:eq(1)").show();
            $(Obj).find("div:eq(1)").find("input").val(m);
            // $(Obj).append("<div class=\"layui-inline\"><input type=\"button\" class=\"layui-btn layui-btn-sm\" value=\"选择\" onclick=\"addGA(this)\"></div>");
            $(Obj).find("div:eq(2)").show();
            $(Obj).find("input:eq(1)").focus();
        }
    }


    function hideGAInput(Obj) {
        var x = $(Obj).val();
        $(Obj).parent("div").prevAll("div").html(x);
        $(Obj).parent("div").nextAll("div").hide();
        $(Obj).parent("div").prevAll("div").show();
        $(Obj).parent("div").hide();
    }

    // function showGoodsInput(Obj) {
    //
    //     $(Obj).find("div:first").hide();
    //     var m = $(Obj).find("div:first").text();
    //     // var a = $(Obj).find(".inputText").val();
    //     if ($(Obj).find("div:eq(1)").css("display")=='none') {
    //         // $(Obj).append("<div class=\"layui-inline\"><input type=\"text\" class=\"layui-input inputText\"  value=\"" + m + "\" onblur=\"hideGAInput(this)\"></div>");
    //         $(Obj).find("div:eq(1)").show();
    //         $(Obj).find("div:eq(1)").find("input").val(m);
    //         // $(Obj).append("<div class=\"layui-inline\"><input type=\"button\" class=\"layui-btn layui-btn-sm\" value=\"选择\" onclick=\"addGA(this)\"></div>");
    //         $(Obj).find("div:eq(2)").show();
    //         $(Obj).find("input:eq(1)").focus();
    //     }
    // }
    //
    //
    // function hideGoodsInput(Obj) {
    //     var x = $(Obj).val();
    //     $(Obj).parent("div").prevAll("div").html(x);
    //     $(Obj).parent("div").nextAll("div").hide();
    //     $(Obj).parent("div").prevAll("div").show();
    //     $(Obj).parent("div").hide();
    // }

    function showQuantityInput(Obj) {

        $(Obj).find("div:first").hide();
        var n = $(Obj).find("div:first").text();
        if ($(Obj).find("div:eq(1)").css("display")=='none') {
            // $(Obj).append("<div class=\"layui-inline\"><input type=\"text\" class=\"layui-input inputText\" value=\"" + n + "\" onblur=\"hideQuantityInput(this)\"></div>");
            $(Obj).find("div:eq(1)").find("input").val(n);
            $(Obj).find("div:eq(1)").show();
            $(Obj).find("input:eq(0)").focus();
        }
    }

    function hideQuantityInput(Obj) {
        var y = $(Obj).val();
        if(y.match("^[1-9]\\d*$")){
            var a = $("[name='goodsId']");
            for (var i=0;i<a.length;i++) {


            }
        }else {

        }
        $(Obj).parent("div").prevAll("div").html(y);
        $(Obj).parent("div").prevAll("div").show();
        $(Obj).parent("div").hide();

    }

    //获得商品对象后加入到列中
    function addGA(Obj) {
        //获得的对象
        // var a = [{id: 1, goodsName: "哇哈哈", price: 100.0}, {id: 2, goodsName: "怡宝", price: 2.00}];
        var warehouseId = $("[name='warehouseId']").val();
        var goodsShelf = $("[name='goodsShelf']").val();
        var shelfLayer = $("[name='shelfLayer']").val();
        var position = $("[name='position']").val();
        var page = $("[name='page']").val();
        var limit = $("[name='limit']").val();



        $.ajax({
            url: "pk/taskOnShelives/listGAIsEmpty",
            type:"POST",
            data:{
                warehouseId : warehouseId,
                goodsShelf : goodsShelf,
                shelfLayer : shelfLayer,
                position : position,
                page : page,
                limit : limit
            },success:function (data) {
                if (!data.successful) {

                }else {

                    if(data.obj.list.length==0){
                        alert("没有符合条件的空余货位了");
                    }else {
                        $("[name='page']").val(parseInt(page)+1);
                        var shelfIdList = $("[name='shelfId']").val();

                        var b = "";
                        for (var i = 0; i < data.obj.list.length; i++) {
                            var a1 = parseInt(data.obj.list[i].volume);
                            var a2 = parseInt(goodsVFirst);
                            var num = parseInt(a1/a2);
                            b = b + "<tr>\n" +
                                "                    <td style=\"padding-bottom: 5px;padding-top: 5px;width: 100px\">\n" +
                                "                        <div class=\"layui-table-cell\" style=\"padding-bottom: 0;padding-top: 0\">\n" +
                                "                            <button type=\"button\" name=\"addNewLine_btn\" class=\"layui-btn layui-btn-normal layui-btn-xs addNewLine_btn\" onclick=\"addTr(this)\">+</button>\n" +
                                "                            <button type=\"button\" name=\"delNowLine_btn\" class=\"layui-btn layui-btn-danger layui-btn-xs delNowLine_btn\" onclick=\"delTr(this)\">×</button>\n" +
                                "                        </div>\n" +
                                "                    </td>\n" +
                                "<!--                    onclick=\"showGAInput(this)\"-->\n" +
                                "                    <td style=\"padding-bottom: 5px;padding-top: 5px;width: 400px\"  class=\"showGAInput\" onclick=\"showGAInput(this)\">\n" +
                                "                        <div class=\"layui-table-cell selGA\" style=\"padding-bottom: 0;padding-top: 0;display: none\">"+ data.obj.list[i].goodsAllocationCode +"</div>\n" +
                                "                        <input type=\"hidden\" name=\"shelfId\" value=\""+ data.obj.list[i].id +"\">\n" +
                                "                        <input type=\"hidden\" name=\"volume\" value=\""+ data.obj.list[i].volume +"\">"+

                                "                        <div class=\"layui-inline\" ><input type=\"text\" class=\"layui-input inputTextGA\"  value=\""+ data.obj.list[i].goodsAllocationCode +"\" onblur=\"hideGAInput(this)\"></div>\n" +
                                "                        <div class=\"layui-inline\" ><input type=\"button\" class=\"layui-btn layui-btn-sm GA_btn\" value=\"选择\" onmousedown=\"addGA(this)\"></div>\n" +
                                "                    </td>\n" +
                            // onclick="showGoodsInput(this)"
                                "                    <td style=\"padding-bottom: 5px;padding-top: 5px;width: 150px\">\n" +
                                "                        <div class=\"layui-table-cell selGoods\" style=\"padding-bottom: 0;padding-top: 0;display: none\"></div>\n" +
                                // "                        <input type=\"hidden\" name=\"goodsId\" value=\"\">\n"
                                 goodsSelect +
                                "                    </td>\n" +
                                "                    <td style=\"padding-bottom: 5px;padding-top: 5px;width: 150px\" onclick=\"showQuantityInput(this)\">\n" +
                                "                        <div class=\"layui-table-cell\" style=\"padding-bottom: 0;padding-top: 0\"></div>\n" +
                                "                        <div class=\"layui-inline\" style=\"display: none\"><input type=\"text\" class=\"layui-input inputText\" value=\"\" onblur=\"hideQuantityInput(this)\"></div>"+
                                "                    </td>\n" +
                                "                    <td style=\"padding-bottom: 5px;padding-top: 5px;width: 100px\">\n" +
                                "                        <div class=\"layui-table-cell\" style=\"padding-bottom: 0;padding-top: 0\">"+ num +"</div>\n" +
                                "                    </td>\n" +
                                "                </tr>"
                        }
                        $(Obj).parents('tr').after(b);
                        $(Obj).parents('tr').remove();
                    }
                }

            }
        });

    }

    $("#freeGA").on('change',"[name='goodsId']",function () {

        var goodsV =$(this).find(":selected").attr("volume");

        var GAV = $(this).parents("tr").find("td:eq(1)").find("[name='volume']").val();

        console.log(goodsV+"=="+GAV);

        var num = parseInt(parseInt(GAV)/parseInt(goodsV));
        if(isNaN(num)){

        }else {
            $(this).parents("tr").find("td:eq(4)").find("div").text(num);
        }
    });




    // function addGoods(Obj) {
    //     var layer = layui.layer;
    //     layer.open({
    //         type: 2,
    //         area: ['900px','510px'],
    //         content: 'onShelives_insert_addGoods.html' //这里content是一个普通的String
    //     });
    // }
</script>
</html>